package com.caesar.exer2;

/**
 * @author caesar
 * @date 2025/7/21
 * @Description:
 * @apiNote
 */
public class Rabbit extends Thread {
    private static boolean flag = true;

    public static boolean isFlag() {
        return flag;
    }

    @Override
    public void run() {
        long start = System.currentTimeMillis();
        for (int i = 1; i <= 30; i++) {
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("兔子跑了" + i + "米");
            if (i == 10 || i == 20) {
                System.out.println("兔子休息了");
                try {
                    Thread.sleep(10000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }


        long end = System.currentTimeMillis();
        flag = false;
        System.out.println("兔子用时：" + (double) (end - start) / 1000.0 + "秒");
    }
}
